/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Business.Region.Country;

import Business.Region.Provincy.Provincy;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 *
 * @author hooting
 */
public class Country {
	private String countryName;
	private List<Provincy> provincyList;
	public Country(String name){
		this.countryName = name;
		provincyList = new ArrayList<Provincy>();
	}
	public void setCountryName(String name){
		this.countryName = name;
	}
	public String getCountryName(){
		return countryName;
	}
	public List<Provincy> getProvincyList(){
		return provincyList;
	}
	public void addProvincy(Provincy p){
		provincyList.add(p);
	}

	public void updateProvincy(Provincy p){
		Iterator<Provincy> ite = provincyList.iterator();
		Provincy updatedP = null;
		while(ite.hasNext()){
			updatedP = ite.next();
			if(updatedP.getProvincyName().equals(p.getProvincyName())){
				break;
			}
		}
		if(updatedP == null){
			return;
		}
		provincyList.remove(updatedP);
		provincyList.add(p);
	}
}
